public class StringDemo1 {

    public static void main(String[] args) {
         //直接赋值，如果字符串常量池中有字符串的话，直接从字符串常量池中取
         String str = "hello";
         //无论字符串常量池中是否有该字符串，都会创建新的对象
         String str2 = new String("word");

         //根据字符数组创建一个字符串
         char[] value = new char[]{'a','b','c'};
         String str3 = new String(value);

         //根据字节数组创建字符串,在网络中有作用
        byte[] bytes = {97,98,99,100};
        String str4 = new String(bytes);

        System.out.println("str:"+str);
        System.out.println("str2:"+str2);
        System.out.println("str3:"+str3);
        System.out.println("str4:"+str4);
    }
}
